<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="css/site.css">
</head>
<body>

	<jsp:include page="header.jsp"></jsp:include>
	
	<jsp:include page="menu.jsp"></jsp:include>
	<div class="container">
		
		<h1>部门列表</h1>
		<form action="dept.do?action=search" method="post">
		关键字: <input type="text" name="key">
		<input type="submit" value="搜索">
		</form>
		<table border="1" width="100%">
			<tr>
				<th>ID</th>
				<th>部门名</th>
				<th>办公室</th>
				<th>电话</th>
				<th>操作</th>
			</tr>
			
			<!-- 解析数据并且显示出来 -->
			<c:if test="${requestScope.depts==null }">
				<!-- 请求转发 -->
				<jsp:forward page="dept.do?action=getAll"></jsp:forward>
			</c:if>
			
			<c:forEach items="${requestScope.depts }" var="dept">
				<tr>
					<td>${dept.did }</td>
					<td>${dept.dname }</td>
					<td>${dept.droom }</td>
					<td>${dept.dphone }</td>
					<td>
						<a href="">修改</a>
						<a href="dept.do?action=remove&did=${dept.did }">删除</a>
					</td>
				</tr>
			</c:forEach>
			
			
		</table>
	
	</div>
</body>
</html>